/*     */package nc.ui.bd.feature.ffile.action;

/*     */
/*     */import java.awt.event.ActionEvent;
/*     */
import javax.swing.KeyStroke;
/*     */
import nc.bs.framework.common.NCLocator;
/*     */
import nc.pubitf.bd.feature.fselect.IFeatureSelectSaveProcess;
/*     */
import nc.uap.rbac.core.dataperm.DataPermissionFacade;
/*     */
import nc.ui.bd.feature.ffile.view.FFileBillForm;
/*     */
import nc.ui.bd.feature.fselect.service.FeatureSelectService;
/*     */
import nc.ui.mmf.framework.action.ActionInitializer;
/*     */
import nc.ui.pubapp.uif2app.model.BillManageModel;
/*     */
import nc.ui.uif2.IShowMsgConstant;
/*     */
import nc.ui.uif2.NCAction;
/*     */
import nc.ui.uif2.ShowStatusBarMsgUtil;
/*     */
import nc.ui.uif2.UIState;
/*     */
import nc.vo.bd.feature.feature.enumeration.SelectTypeEnum;
/*     */
import nc.vo.bd.feature.ffile.constant.FfileConstant;
/*     */
import nc.vo.bd.feature.ffile.entity.AggFFileVO;
/*     */
import nc.vo.bd.feature.ffile.entity.FFileBodyVO;
/*     */
import nc.vo.bd.feature.ffile.entity.FFileHeadVO;
/*     */
import nc.vo.bd.feature.fselect.entity.FeatrueParamVO;
/*     */
import nc.vo.bd.feature.fselect.entity.FeatrueParamVO.Ffiletype;
/*     */
import nc.vo.bd.feature.fselect.entity.FeatrueParamVO.Srctype;
/*     */
import nc.vo.jcom.lang.StringUtil;
/*     */
import nc.vo.pub.lang.UFBoolean;
/*     */
import nc.vo.pub.lang.UFDouble;
/*     */
import nc.vo.uif2.LoginContext;

/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */public class FFileEditAction
/*     */extends NCAction
/*     */{
	/*     */private static final long serialVersionUID = -6255714210218548874L;

	/*     */
	/*     */public FFileEditAction()
	/*     */{
		/* 45 */ActionInitializer.initializeAction(this, "FFileEdit",
				FfileConstant.getFfileEdit());
		/* 46 */putValue("AcceleratorKey", KeyStroke.getKeyStroke(69, 2));
		/*     */}

	/*     */
	/*     */
	/* 50 */private String mdOperateCode = null;
	/*     */
	/* 52 */private String operateCode = null;
	/*     */
	/* 54 */private String resourceCode = null;
	/*     */private FFileBillForm billForm;
	/*     */private BillManageModel model;

	/*     */
	/*     */public FFileBillForm getBillForm() {
		/* 59 */return this.billForm;
		/*     */}

	/*     */
	/*     */public void setBillForm(FFileBillForm billForm) {
		/* 63 */this.billForm = billForm;
		/*     */}

	/*     */
	/*     */
	/*     */public BillManageModel getModel()
	/*     */{
		/* 69 */return this.model;
		/*     */}

	/*     */
	/*     */public void setModel(BillManageModel model) {
		/* 73 */this.model = model;
		/* 74 */this.model.addAppEventListener(this);
		/*     */}

	/*     */
	/*     */public void doAction(ActionEvent e)
	/*     */throws Exception
	/*     */{
		/* 80 */if (checkDataPermission()) {
			/* 81 */AggFFileVO aggvo = (AggFFileVO) getModel()
					.getSelectedData();
			/*     */
			/* 83 */for (FFileBodyVO itBodyVO : aggvo.getChildrenVO()) {
				/* 84 */if ((SelectTypeEnum.MUTILSELECT.equalsValue(itBodyVO
						.getBischoice()))
						|| (SelectTypeEnum.SINGLESELECT.equalsValue(itBodyVO
								.getBischoice())))
				/*     */{
					/* 86 */itBodyVO.setBselect(UFBoolean.TRUE);
					/*     */}
				/*     */}
			/*     */
			/*     */
			/*     */
			/*     */
			/*     */
			/*     */
			/*     */
			/*     */
			/* 97 */FeatrueParamVO param = new FeatrueParamVO();
			/* 98 */param.setBaseprice(new UFDouble(23));
			/* 99 */param.setCanedit(Boolean.valueOf(true));
			/* 100 */param.setCmaterialvid(aggvo.getParentVO()
					.getCmaterialvid());
			/* 101 */param.setPk_group(getModel().getContext().getPk_group());
			/* 102 */param.setSrctype(FeatrueParamVO.Srctype.NOSHOWPRICE);
			/* 103 */param.setfFiletype(FeatrueParamVO.Ffiletype.ISUPDATE);
			/* 104 */param.setFfileid(aggvo.getPrimaryKey());
			/* 105 */param.setFdoctype(aggvo.getParentVO().getFdoctype());
			/* 106 */param.setFeatruecode(aggvo.getParentVO().getVskucode());
			/* 107 */param.setSelectFFileVO(aggvo);
			param.setNodekey("ffile");//
			
			/* 108 */AggFFileVO returnaggvo = new FeatureSelectService().featrueSelect(param, getModel().getContext());
			/* 109 */if (returnaggvo != null) {
				/* 110 */AggFFileVO[] upatevos = ((IFeatureSelectSaveProcess) NCLocator
						.getInstance().lookup(IFeatureSelectSaveProcess.class))
						.fileSaveProcess4In(new AggFFileVO[] { returnaggvo });
				/*     */
				/*     */
				/*     */
				/*     */
				/* 115 */setHead(returnaggvo.getParentVO(),
						upatevos[0].getParentVO());
				/* 116 */getBillForm().showMeUp();
				/* 117 */getModel().directlyUpdate(upatevos);
				/* 118 */ShowStatusBarMsgUtil.showStatusBarMsg(
						FfileConstant.getUpdateSuccessed(),
						this.model.getContext());
				/*     */}
			/* 120 */getModel().setUiState(UIState.NOT_EDIT);
			/*     */}
		/*     */else {
			/* 123 */ShowStatusBarMsgUtil.showErrorMsg(FfileConstant
					.getFfileError(), IShowMsgConstant.getDataPermissionInfo(),
					getModel().getContext());
			/*     */}
		/*     */}

	/*     */
	/*     */
	/*     */private void setHead(FFileHeadVO oldHead, FFileHeadVO newHead)
	/*     */{
		/* 130 */newHead.setCmaterialvid(oldHead.getCmaterialvid());
		/* 131 */newHead.setCmaterialid(oldHead.getCmaterialid());
		/* 132 */newHead.setVskucode(oldHead.getVskucode());
		/* 133 */newHead.setFdoctype(oldHead.getFdoctype());
		/*     */}

	/*     */
	/*     */protected boolean isActionEnable()
	/*     */{
		/* 138 */if ((getModel().getUiState() != UIState.NOT_EDIT)
				&& (getModel().getSelectedData() != null)) {
			/* 139 */return false;
			/*     */}
		/* 141 */if ((getModel().getSelectedOperaDatas() == null)
				|| (getModel().getSelectedOperaDatas().length != 1)) {
			/* 142 */return false;
			/*     */}
		/* 144 */if (getModel().getSelectedOperaDatas() != null) {
			/* 145 */Object[] datas = getModel().getSelectedOperaDatas();
			/* 146 */AggFFileVO aggFFileVO = (AggFFileVO) datas[0];
			/* 147 */if (aggFFileVO.getParentVO().getVsrcid() != null) {
				/* 148 */return false;
				/*     */}
			/*     */}
		/*     */
		/* 152 */return true;
		/*     */}

	/*     */
	/*     */protected boolean checkDataPermission() {
		/* 156 */if (((StringUtil.isEmptyWithTrim(getOperateCode())) && (StringUtil
				.isEmptyWithTrim(getMdOperateCode())))
				|| (StringUtil.isEmptyWithTrim(getResourceCode())))
		/*     */{
			/* 158 */return true;
			/*     */}
		/*     */
		/* 161 */LoginContext context = getModel().getContext();
		/* 162 */String userId = context.getPk_loginUser();
		/* 163 */String pkgroup = context.getPk_group();
		/* 164 */Object data = getModel().getSelectedData();
		/* 165 */boolean hasp = true;
		/* 166 */if (!StringUtil.isEmptyWithTrim(getMdOperateCode())) {
			/* 167 */hasp = DataPermissionFacade
					.isUserHasPermissionByMetaDataOperation(userId,
							getResourceCode(), getMdOperateCode(), pkgroup,
							data);
			/*     */
			/*     */}
		/*     */else
		/*     */{
			/* 172 */hasp = DataPermissionFacade.isUserHasPermission(userId,
					getResourceCode(), getOperateCode(), pkgroup, data);
			/*     */}
		/*     */
		/*     */
		/* 176 */return hasp;
		/*     */}

	/*     */
	/*     */public String getMdOperateCode() {
		/* 180 */return this.mdOperateCode;
		/*     */}

	/*     */
	/*     */public void setMdOperateCode(String mdOperateCode) {
		/* 184 */this.mdOperateCode = mdOperateCode;
		/*     */}

	/*     */
	/*     */public String getOperateCode() {
		/* 188 */return this.operateCode;
		/*     */}

	/*     */
	/*     */public void setOperateCode(String operateCode) {
		/* 192 */this.operateCode = operateCode;
		/*     */}

	/*     */
	/*     */public String getResourceCode() {
		/* 196 */return this.resourceCode;
		/*     */}

	/*     */
	/*     */public void setResourceCode(String resourceCode) {
		/* 200 */this.resourceCode = resourceCode;
		/*     */}
	/*     */
}
